package org.cshoo.sys.command
{
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import org.cshoo.common.util.MessageUtil;
	
	import mx.controls.Alert;
	import mx.rpc.IResponder;
	import mx.rpc.events.ResultEvent;
	
	import org.cshoo.sys.business.MenuDelegate;
	import org.cshoo.sys.event.DeleteMenuEvent;
	import org.cshoo.sys.model.vo.Menu;
	import org.cshoo.sys.event.FindRootMenuListEvent;
	
	public class DeleteMenuCommand implements ICommand, IResponder
	{
		public function execute(event:CairngormEvent):void
		{
			var menu:Menu = (event as DeleteMenuEvent).menu;
			var menuDelegate:MenuDelegate = new MenuDelegate(this);
			menuDelegate.deleteMenu(menu);
		}
		
		public function result(event:Object):void
		{
			if((event as ResultEvent).result as Boolean)
			{
				MessageUtil.showInfoMessage("菜单数据删除成功");
				//重新刷新menu列表
				var e:FindRootMenuListEvent = new FindRootMenuListEvent();
				e.dispatch();
			}
			else
				MessageUtil.showErrorMessage("菜单数据删除失败");
		}
		
		public function fault(info:Object):void
		{
			Alert.show("服务器连接已经断开");
		}
	}
}